﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Knowledgecast.Twitter.WPF.App
{
    /// <summary>
    /// Interaction logic for NewSearch.xaml
    /// </summary>
    public partial class NewSearch : Window
    {
        public NewSearch()
        {
            InitializeComponent();
        }

        public string Query { get; set; }

        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtQuery.Text) == false)
            {
                Search();
            }
        }

        void Search()
        {
            DialogResult = true;
            Query = txtQuery.Text;
            Close();
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            txtQuery.Focus();
        }

        private void txtQuery_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter && String.IsNullOrEmpty(txtQuery.Text) == false)
            {
                Search();
            }
        }
    }
}
